﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TJBHJJ.Models;

namespace TJBHJJ.Controllers
{
    public class MessageController : Controller
    {
        //
        // GET: /Message/

        //public ActionResult Index()
        //{
        //    return View();
        //}
        Home home = new Home();
        public ActionResult Add()
        {
            return View(new Message());
        }
        [HttpPost]
        public ActionResult Add(Message msg)
        {
            if (msg != null && ModelState.IsValid)
            {
                msg.AddTime = DateTime.Now;
                msg.Isread = false;
                msg.Isdispaly = false;
                msg.ReplyContent = "";
                msg.UserId = 0;
                msg.IP = Request.UserHostAddress;
                home.DbInfo.AddToMessage(msg);
                home.DbInfo.SaveChanges();
                home.Alert(Response, "提交成功，管理员会尽快处理");

            }
            return RedirectToAction("Add");
        }

    }
}
